package com.itheima.mapper;

import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Mapper层
 */
@Mapper
public interface DeptMapper {

    /**
     * 查询所有部门
     *
     * @return
     */
    @Select("select * from dept order by update_time desc")
    List<Dept> list();

    /**
     * 添加部门
     *
     * @param dept
     */
    void insert(Dept dept);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Select("select * from dept where id=#{id}")
    Dept getById(Integer id);

    /**
     * 根据id修改
     *
     * @param dept
     */
    void updateById(Dept dept);

    /**
     * 根据id删除
     *
     * @param id
     */
    @Delete("delete from dept where id=#{id}")
    void deleteById(Integer id);
}
